<template>
  <div>
    <el-card class="box-card" shadow="hover">
      <el-form :model="systemSetting" label-width="80px" size="mini">
        <el-tabs>
          <el-tab-pane label="基本信息">
            <el-form-item label="名称">
              <el-input v-model="systemSetting.baseInfoSetting.name"/>
            </el-form-item>
            <el-form-item label="版本">
              <el-input v-model="systemSetting.baseInfoSetting.version"/>
            </el-form-item>
            <el-form-item label="描述">
              <el-input v-model="systemSetting.baseInfoSetting.desc"/>
            </el-form-item>
            <el-form-item label="URL">
              <el-input v-model="systemSetting.baseInfoSetting.url"/>
            </el-form-item>
          </el-tab-pane>
          <el-tab-pane label="钉钉配置">
            <el-form-item label="AppKey">
              <el-input v-model="systemSetting.dingTalkSetting.miniAppKey"/>
            </el-form-item>
            <el-form-item label="AppSecret">
              <el-input v-model="systemSetting.dingTalkSetting.miniAppSecret"/>
            </el-form-item>
          </el-tab-pane>
          <el-tab-pane label="Jenkins配置">
            <el-form-item label="地址">
              <el-input v-model="systemSetting.jenkinsSetting.url"/>
            </el-form-item>
            <el-form-item label="用户名">
              <el-input v-model="systemSetting.jenkinsSetting.username"/>
            </el-form-item>
            <el-form-item label="Token">
              <el-input v-model="systemSetting.jenkinsSetting.password"/>
            </el-form-item>
            <el-form-item label="Git证书ID">
              <el-input v-model="systemSetting.jenkinsSetting.gitCredentialsId"/>
            </el-form-item>
          </el-tab-pane>

          <el-tab-pane label="SSH配置">
            <el-form-item label="SSH公钥">
              <el-input v-model="systemSetting.sshSetting.pubKey" :rows="10" autosize type="textarea"/>
            </el-form-item>
            <el-form-item label="SSH密钥">
              <el-input v-model="systemSetting.sshSetting.priKey" :rows="5" autosize type="textarea"/>
            </el-form-item>
          </el-tab-pane>

          <el-tab-pane label="腾讯云配置">
            <el-form-item label="SecretId">
              <el-input v-model="systemSetting.tencentSetting.secretId"/>
            </el-form-item>
            <el-form-item label="SecretKey">
              <el-input v-model="systemSetting.tencentSetting.secretKey"/>
            </el-form-item>
            <el-form-item label="区域">
              <el-input v-model="systemSetting.tencentSetting.region"/>
            </el-form-item>
            <el-form-item label="日志集">
              <el-input v-model="systemSetting.tencentSetting.logsetName"/>
            </el-form-item>
          </el-tab-pane>
        </el-tabs>
        <el-form-item>
          <el-button type="primary" @click="onSave">保存</el-button>
        </el-form-item>
      </el-form>
    </el-card>
  </div>
</template>
<script>


import {getSystemSettingApi, saveSystemSettingApi} from "@/api/manage";

export default {
  data() {
    return {
      systemSetting: {baseInfoSetting: {}, dingTalkSetting: {}, jenkinsSetting: {}, sshSetting: {}, tencentSetting: {}},
    };
  },
  methods: {
    async onSave() {
      await saveSystemSettingApi(this.systemSetting);
      this.$message({message: `保存成功`, type: "success",});
    }
  },
  async created() {
    this.systemSetting = await getSystemSettingApi()
  }
};
</script>
